<template>
  <div class="head">
    <div class="tit">
      <button class="tex1">中转费报表</button>
    </div>
    <div class="line" />
    <el-row>
      <el-col :span="24">
        <div class="title1">
          <el-form ref="form" :model="form" label-width="80px">
            <div class="form">
              <el-form-item label="日期维度">
                <el-select
                  v-model="form.timeType"
                  class="input"
                  placeholder="请选择"
                  style="width: 286px"
                >
                  <el-option label="寄件日期" value="1" />
                  <el-option label="结算日期" value="2" />
                </el-select>
              </el-form-item>
              <el-form-item label="汇总层级">
                <el-select
                  v-model="value1"
                  placeholder="请选择"
                  style="width: 286px"
                  @change="changeType"
                >
                  <el-option label="网点" value="1" />
                  <el-option label="承包区" value="2" />
                  <el-option label="转运中心" value="3" />
                  <el-option label="网点+转运中心" value="4" />
                </el-select>
              </el-form-item>
              <el-form-item label="网点名称">
                <el-select
                  v-model="form.networkName"
                  :disabled="true"
                  placeholder="辽宁盘锦公司"
                  style="width: 286px"
                >
                  <el-option label="辽宁盘锦公司" value="1" />
                </el-select>
              </el-form-item>
              <el-form-item class="text" label="承包区">
                <el-select
                  v-model="form.contractAreaNameId"
                  class="input"
                  placeholder="请选择"
                  style="width: 286px"
                >
                  <el-option
                    v-for="item in ShowCoverAreaList"
                    :key="item.id"
                    :label="item.networkName"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSubmit">查询</el-button>
                <el-button @click="khClear">重置</el-button>
              </el-form-item>
            </div>
            <div class="form1">
              <el-form-item label="转运中心">
                <el-select
                  v-model="form.transferCentreId"
                  class="input"
                  placeholder="请选择"
                  style="width: 286px"
                >
                  <el-option
                    v-for="item in TransferCenterList"
                    :key="item.id"
                    :label="item.transferCenter"
                    :value="item.id"
                  />
                </el-select>
              </el-form-item>
              <el-form-item style="flex: 1" class="text" label="日期">
                <el-date-picker
                  v-model="value"
                  type="daterange"
                  start-placeholder="开始日期"
                  end-placeholder="结束日期"
                  value-format="yyyy-MM-dd"
                  style="width: 698px"
                  @change="changeTime"
                />
              </el-form-item>
              <el-form-item>
                <el-button @click="onSubmit"
                  ><i class="el-icon-upload2" />导出</el-button
                >
              </el-form-item>
            </div>
          </el-form>
        </div>

        <el-table
          :data="tableData"
          border
          max-height="734"
          :header-cell-style="{ background: '#f6f6f6' }"
          style="width: 100%"
        >
          <el-table-column
            type="index"
            :index="table_index"
            width="50"
            align="center"
          />
          <el-table-column
            prop="timePeriod"
            label="时间段"
            width="180"
            align="center"
          />
          <el-table-column
            v-if="
              this.value1 === '1' || this.value1 === '2' || this.value1 === '4'
            "
            prop="networkNameId"
            width="110"
            label="始发网点编码"
            align="center"
          />
          <el-table-column
            v-if="
              this.value1 === '1' || this.value1 === '2' || this.value1 === '4'
            "
            prop="networkName.networkName"
            width="110"
            label="始发网点名称"
            align="center"
          />
          <el-table-column
            v-if="this.value1 === '3' || this.value1 === '4'"
            prop="hqTransferCentre.transferCode"
            label="转运中心编码"
            width="110"
            align="center"
          />
          <el-table-column
            v-if="this.value1 === '3' || this.value1 === '4'"
            prop="hqTransferCentre.transferCenter"
            label="转运中心名称"
            width="110"
            align="center"
          />
          <el-table-column label="中转预收" align="center">
            <el-table-column
              prop="preSettleAmount"
              width="120"
              label="预收结算金额"
              align="center"
            />
            <el-table-column
              prop="preSettleNum"
              width="120"
              label="预收结算票件量"
              align="center"
            />
          </el-table-column>
          <el-table-column label="中转调整" align="center">
            <el-table-column
              prop="adjustSettleAmount"
              width="120"
              label="调整结算金额"
              align="center"
            />
            <el-table-column
              prop="adjustSettleNum"
              width="120"
              label="调整结算票件量"
              align="center"
            />
            <el-table-column
              prop="adjustAscendSettleAmount"
              width="120"
              label="追溯结算金额"
              align="center"
            />
            <el-table-column
              prop="adjustAscendSettleNum"
              width="120"
              label="追溯结算票件量"
              align="center"
            />
          </el-table-column>
          <el-table-column label="中转加收" align="center">
            <el-table-column
              prop="addSettleAmount"
              width="120"
              label="加收结算金额"
              align="center"
            />
            <el-table-column
              prop="addSettleNum"
              width="120"
              label="加收结算票件量"
              align="center"
            />
            <el-table-column
              prop="addAscendSettleAmount"
              width="120"
              label="追溯结算金额"
              align="center"
            />
            <el-table-column
              prop="addAscendSettleNum"
              width="120"
              label="追溯结算件量"
              align="center"
            />
          </el-table-column>
          <el-table-column prop="totalAmount" label="合计" align="center" />
        </el-table>
        <div
          style="
            display: flex;
            justify-content: space-between;
            margin-top: 51px;
          "
        >
          <div class="title2" />
          <div class="block" style="display: flex; justify-content: flex-end">
            <el-pagination
              background
              :current-page="current"
              :page-sizes="[10, 20, 30, 40]"
              :page-size="10"
              layout="total, prev, pager, next"
              :total="+total"
              prev-text="上一页"
              next-text="下一页"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import {
  ShowCoverAreaApi,
  TransferCenterApi,
  SummaryLevelApi1,
  SummaryLevelApi2,
  SummaryLevelApi3,
  SummaryLevelApi4,
} from "@/api/HqFinancePanel";

export default {
  data() {
    return {
      value: "",
      value1: "1",
      form: {
        collectType: 0,
        contractAreaNameId: "",
        endTime: "",
        networkNameId: "",
        pageDate: {
          pageNum: 0,
          pageSize: 0,
        },
        startTime: "",
        timeType: "",
        transferCentreId: "",
      },
      tableData: [],
      ShowCoverAreaList: [], // 承包区列表
      TransferCenterList: [], // 转运中心
      current: 0, // 页数
      pages: 0, // 条数
      total: 0, // 总数
    };
  },
  created() {
    this.ShowCoverArea();
    this.TransferCenter();
  },
  methods: {
    handleSizeChange(val) {
      this.form.pageDate.pageSize = val;
      this.onSubmit();
    },
    handleCurrentChange(val) {
      this.form.pageDate.pageNum = val;
      this.onSubmit();
    },
    // 序号
    table_index(index) {
      return (
        (this.form.pageDate.pageNum - 1) * this.form.pageDate.pageSize +
        index +
        1
      );
    },
    // 选择时间
    changeTime() {
      if (this.value != null) {
        this.form.startTime = this.value[0];
        this.form.endTime = this.value[1];
      }
    },
    // 承包区
    async ShowCoverArea() {
      const res = await ShowCoverAreaApi();
      this.ShowCoverAreaList = res.data;
    },
    // 转运中心
    async TransferCenter() {
      const res = await TransferCenterApi();
      this.TransferCenterList = res.data;
      console.log(res);
    },
    table(res) {
      this.tableData = res.data.data;
      this.total = res.data.total;
      this.current = res.data.current;
      this.pages = res.data.pages;
    },
    // 查询
    async onSubmit() {
      // 接口修改
    },
    changeType() {
      this.tableData = [];
    },
    // 重置
    khClear() {
      Object.keys(this.form).forEach((key) => {
        if (key !== "pageDate" && key !== "networkNameId") {
          this.form[key] = "";
        }
      });
      this.tableData = [];
      this.value = "";
      this.value1 = "1";
      this.total = 0;
      this.current = 0;
      this.pages = 0;
    },
  },
};
</script>
<style scoped lang="scss">
.form {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.form1 {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.tit {
  display: flex;

  .tex1 {
    margin-right: 48px;
    font-size: 16px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    background: #fff;
    border: 1px #fff solid;
  }

  .active {
    font-family: Source Han Sans CN;
    font-weight: 700;
    color: #2087d0;
    position: relative;
  }

  .active::before {
    position: absolute;
    content: "";
    width: 62px;
    height: 2px;
    background: #2087d0;
    border-radius: 1px;
    bottom: -20px;
    left: 50%;
    transform: translate(-50%);
  }
}

.head {
  padding: 30px;
}

.title {
  font-size: 16px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
  margin-top: 20px;
}

.line {
  height: 1px;
  background: #d8d8d8;
  border-radius: 1px;
  margin-top: 19px;
}

.title1 {
  margin: 20px 0;
  .text {
    font-size: 18px;
    font-family: Source Han Sans CN;
    font-weight: 400;
    color: #666666;
    flex: 1;
    .input {
      width: 286px;
      height: 36px;
      background: #ffffff;
      border-radius: 4px;
    }

    .input1 {
      width: 708px;
      height: 36px;
      background: #ffffff;
      border: 1px solid #b4b4b4;
      border-radius: 4px;
    }
  }
}

.title2 {
  font-size: 18px;
  font-family: Source Han Sans CN;
  font-weight: 400;
  color: #666666;
}
</style>
